package tt.dz.appserver.util;

import java.util.Random;

/**
 * 字符串帮助
 * @author Administrator
 *
 */
public class StringUtils {

	/**
	 * 获取合法经纬度
	 * @param latOrLng
	 * @return
	 */
	public static final String getDealLatOrLng(String latOrLng){
		
		if(org.springframework.util.StringUtils.isEmpty(latOrLng)){
			return "0.000000";
		}
		//查找经纬度的“.”
		int index = latOrLng.indexOf(".");
		
		if(index==-1){
			return latOrLng+".000000";
		}
		//获取小数点后面的长度
		String suffix = latOrLng.substring(index);
		//判断查询
		if(suffix.length()>6){
			return latOrLng.substring(0, index + 1 + 6);
		}
		return latOrLng;
	}
	public static final String fill (String parm,int length){
		
		if(parm.length()>=length){
			return parm;
		}else{
			return fill("0"+parm,length);
		}		
	}
	
	
	/**
	 * 随机生成字符串
	 * @param length
	 * @return
	 */
	 public static String getRandomString(int length){  
	        String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";  
	        Random random = new Random();  
	        StringBuffer sb = new StringBuffer();  
	          
	        for(int i = 0 ; i < length; ++i){  
	            int number = random.nextInt(62);//[0,62)  
	              
	            sb.append(str.charAt(number));  
	        }  
	        return sb.toString();  
	    }  
		public static Boolean isNotBlank(String s) {
			if(s == null || s.length() <= 0){
				return false;
			}
			return true;
		}
}
